<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>

    function addTwo(num1, num2) {
        var sum = num1 + num2;
        return sum;//把结果返回给调用方,并且结束函数
    }

    var p = addTwo(1, 2);
    document.writeln(p);
</script>

</html>